local JohnnyKlebitz = {}
JohnnyKlebitz.peds = {}
JohnnyKlebitz.howMany = 2
function JohnnyKlebitz.unload()
	for k,guard in pairs(JohnnyKlebitz.peds) do
		if( guard ~= nil) then
			PED.DELETE_PED(guard)
			JohnnyKlebitz.peds[k] = nil
		end
	end
end

function JohnnyKlebitz.tick()
	if(get_key_pressed(35)) then
		local JohnnySkinID = GAMEPLAY.GET_HASH_KEY("ig_JohnnyKlebitz")
		local playerPed = PLAYER.PLAYER_PED_ID()
		local player = PLAYER.GET_PLAYER_PED(playerPed)
		local playerID = PLAYER.PLAYER_ID()
		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)
		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)
		JohnnyKlebitz.unload()
		STREAMING.REQUEST_MODEL(JohnnySkinID)
		while(not STREAMING.HAS_MODEL_LOADED(JohnnySkinID)) do
				wait(50)
		end
		for i = 0 ,JohnnyKlebitz.howMany,1 do
			JohnnyKlebitz.peds[i] = PED.CREATE_PED( 26,JohnnySkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)	
			PED.SET_PED_CAN_SWITCH_WEAPON(JohnnyKlebitz.peds[i],false)
			WEAPON.GIVE_DELAYED_WEAPON_TO_PED(JohnnyKlebitz.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_RAILGUN"), 1000, false)
			PED.SET_PED_AS_GROUP_MEMBER(JohnnyKlebitz.peds[i], playerGroup)
			ENTITY.SET_ENTITY_INVINCIBLE(JohnnyKlebitz.peds[i], true);
		end
		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(JohnnySkinID)
	end
end

return JohnnyKlebitz